﻿using Coldairarrow.Business;
using Coldairarrow.Entity;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers
{
    [Route("/Comment/[controller]/[action]")]
    public class Order_DecimalController : BaseApiController
    {
        #region DI

        public Order_DecimalController(IOrder_DecimalBusiness order_DecimalBus)
        {
            _order_DecimalBus = order_DecimalBus;
        }

        IOrder_DecimalBusiness _order_DecimalBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<Order_Decimal>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _order_DecimalBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<Order_Decimal> GetTheData(IdInputDTO input)
        {
            return await _order_DecimalBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(Order_Decimal data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _order_DecimalBus.AddDataAsync(data);
            }
            else
            {
                await _order_DecimalBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _order_DecimalBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}